package com.winsdom.service.count.impl;

import com.winsdom.entity.count.BillingDetailsPageResult;
import com.winsdom.entity.count.BillingDetailsQueryRequest;
import com.winsdom.entity.count.BillingDetailsVO;
import com.winsdom.mapper.count.BillingDetailsMapper;
import com.winsdom.service.count.BillingDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillingDetailsServiceImpl implements BillingDetailsService {

    @Autowired
    private BillingDetailsMapper billingDetailsMapper;

    @Override
    public BillingDetailsPageResult getBillingDetailsList(Integer pageNum, Integer pageSize) {
        // 获取总记录数
        long total = billingDetailsMapper.selectTotalCount();
        
        // 计算偏移量
        int offset = (pageNum - 1) * pageSize;
        
        // 查询当前页数据
        List<BillingDetailsVO> list = billingDetailsMapper.selectBillingDetailsList(offset, pageSize);
        
        // 返回分页结果
        return BillingDetailsPageResult.of(list, total, pageNum, pageSize);
    }

    @Override
    public BillingDetailsPageResult getBillingDetailsWithCondition(BillingDetailsQueryRequest request) {
        // 获取总记录数
        long total = billingDetailsMapper.selectTotalCountWithCondition(request);
        
        // 查询当前页数据
        List<BillingDetailsVO> list = billingDetailsMapper.selectBillingDetailsWithCondition(request);
        
        // 返回分页结果
        return BillingDetailsPageResult.of(list, total, request.getPageNum(), request.getPageSize());
    }
} 